package com.lc1993929.mr.flow;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by LiuChang on 2017/11/6/006.
 */
public class FlowSumMapper extends Mapper<LongWritable, Text, Text, FlowBean> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] split = line.split("\t");
        String phone = split[1].trim();
        long upflow = Long.parseLong(split[split.length - 3]);
        long dflow = Long.parseLong(split[split.length - 2]);
        FlowBean flowBean = new FlowBean(upflow, dflow);
        context.write(new Text(phone), flowBean);
    }
}
